package org.thomias.exo6.monitor;

public class Task implements Runnable {

	protected String name;
	protected boolean bIsComplete;
	public long startTime;

	public Task(String name) {
		this.name = name;
		bIsComplete = false;
		startTime = -1;
	}

	public boolean isComplete() {
		return bIsComplete;
	}

	@Override
	public void run() {
		setStartTime();
		try {
			Thread.sleep((long) (5000 + 3000 * Math.random()));
		} catch (InterruptedException e) {
		}
		setComplete(true);
	}

	protected void setStartTime() {
		this.startTime = System.currentTimeMillis();
	}

	public boolean hasStarted() {
		return startTime != -1;
	}

	public void setComplete(boolean b) {
		this.bIsComplete = b;
	}

}
